$(getData);

function refresh(){
	getData();
}

function getData(){
	$.proAjax({
		url:"/mobile/energy",
		dataType:"json",
		success:function(data){
			$("#wan").hide();
			for( var key in data){
				if(key!="totalCap"　&& key!="trees")
				if(data[key]>=10000){
					$("#"+key).html((data[key]/10000||0).toFixed(2));
					$("#"+key).next().remove();
					$("#"+key).after("<span>万</span>");
				}else{
					$("#"+key).html((data[key]||0).toFixed(2));
					$("#"+key).next("span").remove();
				}
			}
			if(data['totalCap']>=10000){
				var dnum = 2;
				$("#totalCap").text((data['totalCap']/10000||0).toFixed(dnum));
				$("#wan").show();
			}else{
				var dnum = 2;
				$("#totalCap").text((data['totalCap']||0).toFixed(dnum));
			}
			if(data['trees']>=10000){
				$("#trees").text((data['trees']/10000||0).toFixed(2));
				$("#trees").next().remove();
				$("#trees").after("<span>万</span>");
			}else{
				$("#trees").text((data['trees']||0).toFixed(0));
				$("#trees").next("span").remove();
			}
		}
			
		
	});
}